define(['Widget','jquery','jqueryUI'],function(Widget,$,$UI){
	function Window(){
		this.cfg={
			content:'Hello World!',
			width:500,
			height:300,
			title:'系统消息',
			hasCloseBtn:false,
			handler4AlertBtn:null,
			handler4CloseBtn:null,
			okContent:'确定',
			hasMask:true,
			isDraggable:true,
		};
	}
	Window.prototype=$.extend({},new Widget.Widget(),{
		alert:function(cfg){
			var self=this;
			var CFG=$.extend(this.cfg,cfg);
			var temple='<div class="window_boundingBox">'+
							'<div class="window_boundingHeader">'+CFG.title+'</div>'+
							'<div class="window_boundingContent">'+CFG.content+'</div>'+
							'<div class="window_boundingButton"></div>'+
						'</div>';
			var boundingBox=$(temple);
			//boundingBox.append(close);
			//boundingBox.html(CFG.content);		
			var close=$('<input type="button" value="'+CFG.okContent+'" class="ok"></input>');
			if(CFG.handler4AlertBtn){
				self.on('alert',CFG.handler4AlertBtn);
				//Widget.prototype.on.call(self,'alert',CFG.handler4AlertBtn);
			}
			close.click(function(){
				//CFG.handler4AlertBtn && CFG.handler4AlertBtn();
				/*
				var i=0,len=self.handlers.length;
				for(;i<len;i++){
					if(self.handlers[i][0]=="alert"){
						self.fire(self.handlers[i][1]);
					}
				}*/
				//Widget.prototype.on.fire(self,'alert');
				self.fire('alert');
				boundingBox.remove();
				mask && mask.remove();
			});
			boundingBox.css({
				width:CFG.width+'px',
				height:CFG.height+'px',
				left:(CFG.x || (window.innerWidth-CFG.width)/2)+'px',
				top:(CFG.y|| (window.innerHeight-CFG.height)/2)+'px',
				margin:'-'+CFG.width/2+'px'
			});
			var mask=null;
			if(CFG.hasMask){
				mask=$('<div class="window_boundingMask"></div>')
				mask.appendTo('body');
			}
			boundingBox.addClass(CFG.skinClassName);
			boundingBox.appendTo('body');
			if(CFG.handler4CloseBtn){
						self.on('close',CFG.handler4CloseBtn);
						//Widget.prototype.on.call(self,'close',CFG.handler4CloseBtn);
			}
			if(CFG.hasCloseBtn){
				var btn=$('<input type="button" value="X" class="close"></input>');
				boundingBox.append(btn);
				btn.on('click',function(){
					if(self.handlers['close'].length>0){
						self.fire('close');
						//Widget.prototype.on.fire(self,'close');
					}else{
						boundingBox.remove();	
						mask &&　mask.remove();
					}
					
				});
			}
			if(CFG.isDraggable){
				if(CFG.dragHandle){
					boundingBox.draggable({handle:CFG.dragHandle});
				}else{
					boundingBox.draggable();	
				}
				
			}
			$(".window_boundingButton").append(close);
			return self;
			
		},
		confirm:function(){
			alert('confirm');
		},
		prompt:function(){
			alert('prompt');
		}
	})
	return{
		Window:Window
	}
});